package ui;

import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.layout.HorizontalLayout;
import org.uqbar.arena.layout.VerticalLayout;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.windows.Window;
import org.uqbar.arena.windows.WindowOwner;
import org.uqbar.commons.model.ObservableObject;
import org.uqbar.commons.utils.ApplicationContext;

import Aplicacion.Captura;
import Homes.CapturasHome;

@SuppressWarnings("serial")
public class MainWindows extends Window<ObservableObject> {
	
	public MainWindows(WindowOwner owner, ObservableObject model) {
		super(owner, model); 
	}

	private Panel mainPanel;

	@Override
	public void createContents(Panel mainPanel) {
		this.mainPanel = mainPanel;
		mainPanel.setLayout(new VerticalLayout());
		this.createButtons();
	} 
	
	private void createButtons() {
		Panel buttonPanel = new Panel(this.mainPanel).setLayout(new HorizontalLayout());
		new Button(buttonPanel)
			.setCaption("Ingresar Captura")
			.onClick(new MessageSend(this, "ingresarCaptura"));
		new Button(buttonPanel)
			.setCaption("Ingresar Patente Manualmente")
			.onClick(new MessageSend(this, "ingresarPatente"));
		new Button(buttonPanel)
		.setCaption("Consultar Pendientes")
		.onClick(new MessageSend(this, "consultarPendientes"));
	}
	
	public void ingresarCaptura() {
		new IngresarCapturaWindow(this, (CapturasHome)ApplicationContext.getInstance().getHome(Captura.class)).open();
	}
	
	public void ingresarPatente() {
		new IngresarPatenteWindow(this, (CapturasHome)ApplicationContext.getInstance().getHome(Captura.class)).open();
	}
	
	public void consultarPendientes() {
		new ConsultarPendientesWindow(this, (CapturasHome)ApplicationContext.getInstance().getHome(Captura.class)).open();
	}

}
